package com.cloudfun.campusshare.common.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by Huqin on 2020/1/17
 */
public enum DeviceType {
    BXY6_5(BaseConstant.BXY6_5_NAME, "波轮6.5公斤洗衣机-无消毒", ProductType.WASHING_MACHINE),
    BXYD6_5(BaseConstant.BXYD6_5_NAME, "波轮6.5公斤洗衣机-有消毒", ProductType.WASHING_MACHINE),
    BXX6_5(BaseConstant.BXX6_5_NAME, "波轮6.5公斤洗鞋机", ProductType.WASHING_SHOES_MACHINE),
    GXY8(BaseConstant.GXY8_NAME, "滚筒8公斤洗衣机", ProductType.WASHING_MACHINE),
    GXY13_5(BaseConstant.GXY13_5_NAME, "滚筒13.5公斤洗衣机", ProductType.WASHING_MACHINE),
    GGY8(BaseConstant.GGY8_NAME, "滚筒8公斤干衣机", ProductType.DRY_MACHINE),
    GGY13_5(BaseConstant.GGY13_5_NAME, "滚筒13.5公斤干衣机", ProductType.DRY_MACHINE),
    GGY6(BaseConstant.GGY6_NAME, "滚筒6公斤干衣机", ProductType.DRY_MACHINE),
    PUMP_LA_1(BaseConstant.PUMP1_LA_NAME,"单泵",ProductType.LIQUID_PUMP),
    PUMP_LA_2(BaseConstant.PUMP2_LA_NAME,"双泵",ProductType.LIQUID_PUMP);


    private String name;
    private String desc;
    private ProductType productType;

    DeviceType(String name, String desc, ProductType productType) {
        this.name = name;
        this.desc = desc;
        this.productType = productType;
    }

    DeviceType(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public ProductType getProductType() {
        return productType;
    }

    public static DeviceType getDeviceTypeByName(String name) {
        if (StringUtils.isBlank(name)) {
            return null;
        }
        DeviceType[] values = DeviceType.values();
        for (DeviceType val : values) {
            if (val.getName().equals(name)) {
                return val;
            }
        }
        return null;
    }

    public static String getDescByName(String name) {
        DeviceType[] values = DeviceType.values();
        for (DeviceType deviceType : values) {
            if (deviceType.name.equals(name)) {
                return deviceType.desc;
            }
        }
        return "";
    }
}
